package com.shoulder.core.utils;

import org.slf4j.MDC;

public class LogTraceUtils {
    public static final String TRACE_ID = "traceId";

    public static String get() {
        String traceId = MDC.get(TRACE_ID);
        return traceId == null ? "" : traceId;
    }

    public static void set(String traceId) {
        MDC.put(TRACE_ID, traceId);
    }

    public static void set() {
        MDC.put(TRACE_ID, new IdUtils(1, 1).nextId() + "");
    }

    public static void remove() {
        MDC.remove(TRACE_ID);
    }

    public static void clear() {
        MDC.clear();
    }
}
